
var ChessScan = {
	SCAN_DIR_HORIZONTAL:        0,
	SCAN_DIR_OBLIQUE45:         1,
	SCAN_DIR_VERTICAL:          2,
	SCAN_DIR_OBLIQUE135DGREE:   3,
	SCAN_DIR_COUNTS:            4,


	init: function() {
		this.calCoordMethodArray = new Array(
							new Array(this.calCoordMethod(1), this.calCoordMethod(0)),
							new Array(this.calCoordMethod(1), this.calCoordMethod(-1)),
							new Array(this.calCoordMethod(0), this.calCoordMethod(-1)),
							new Array(this.calCoordMethod(1), this.calCoordMethod(1)));
	},

	calCoordMethod: function(val) {
		var k = val;
		
		function calCoord(xy, id) {
			return xy + k * id;
		}
		
		return calCoord;
	},

	scan: function(x, y, direct) {
		var X, Y;
		var result = "";
		
		for (var i = -4; i < 5; i++) {
			X = this.calCoordMethodArray[direct][0](x, i);
			Y = this.calCoordMethodArray[direct][1](y, i);

			if ((X >= 0 && X < ChessInfo.chessboardcolumns) && (Y >=0 && Y < ChessInfo.chessboardrows)) {
				//result += ChessInfo.getCell(X, Y).getAttribute("chess");
				result += ChessInfo.cbtracker.getChess(X, Y);
			}
		}
		return result;
	}
};